import Vue from 'vue'
import App from './App.vue'
import router from './library/router/library'
import {axios,get,post} from '@/library/api/request'
import * as api from '@/library/api/request'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import timeFormatter from '@/library/api/format-time.js'
import store from '@/library/router/store'

Vue.use(ElementUI)

Vue.config.productionTip = false
Vue.prototype.$axios = axios
Vue.prototype.$get = get
Vue.prototype.$post = post
Vue.prototype.$api = api

Object.keys(timeFormatter).forEach(key=>{
  Vue.prototype[key] = timeFormatter[key],
  Vue.filter(key,timeFormatter[key]);
})

Vue.directive('color',{
  bind(el) {
    let color = "#EC4141"
    el.style.backgroundColor = color
  },
  update(el,binding) {
    let color = binding.value.isColor
    el.style.backgroundColor = color
  }
})

router.beforeEach((to, from, next) => {
/* 路由发生变化修改页面title */
if (to.meta.title) {
    document.title = to.meta.title
}
    next()
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
